package com.laomou.logdog;

import com.laomou.logdog.controller.MainController;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;

import java.net.URL;

public class Main extends Application {
    private static final String APPNAME = "LogDog";
    private static final String VERSION = "v1.0 beta";
    private static final int VERSIONCODE = 20160418;

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(final Stage primaryStage) throws Exception {
        URL url = getClass().getResource("/res/layout/main.fxml");
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(url);
        Parent root = loader.load();
        final MainController controller = loader.getController();
        primaryStage.setOnCloseRequest(arg0 -> {
            controller.onClose();
            primaryStage.hide();
        });
        primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/res/layout/icon.png")));
        primaryStage.setTitle(APPNAME + " " + VERSION);
        primaryStage.setScene(new Scene(root, 1100, 600));
        primaryStage.show();
    }
}
